// haxzs audio sevrer
// made by omghaxzs
// 2011

#include "client_manager.h"

client_manager::client_manager(boost::asio::io_service *io, int maxClients, int maxThreads) : source(io) {
    // Assign our maximum client and thread count
    this->clients.reserve(maxClients);
    this->threadPool.reserve(maxThreads);
    this->started = false;
}

void client_manager::start() {
    this->started = true;
    // Let's initialize our three threads!
    this->m_ListeningThread = boost::shared_ptr<boost::thread>(new boost::thread(boost::bind(&client_manager::listenForClients, this)));
    
    this->m_ProcessingThread = boost::shared_ptr<boost::thread>(new boost::thread(boost::bind(&client_manager::processClients, this)));
    
    this->m_DiagnosticThread = boost::shared_ptr<boost::thread>(new boost::thread(boost::bind(&client_manager::diagnoseClients, this)));
    
    // Wait for one of them to end
    this->m_ListeningThread->join();
}

bool client_manager::listenForClients() {
    while(this->started) {
        // Sleep for a bit
        boost::this_thread::sleep(boost::posix_time::seconds(5));
    }
    return true;
}

bool client_manager::processClients() {
    while(this->started) {
        // Sleep for a bit
        boost::this_thread::sleep(boost::posix_time::seconds(5));
    }
}

bool client_manager::diagnoseClients() {
    while(this->started) {
        // Sleep for a bit
        boost::this_thread::sleep(boost::posix_time::seconds(5));
    }
}
